package org.ycx.upms.dao.auto;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.ycx.upms.dao.model.SecPageEle;
import org.ycx.upms.dao.model.SecPageEleExample;

import java.util.List;

public interface SecPageEleMapper {
    @SelectProvider(type=SecPageEleSqlProvider.class, method="countByExample")
    long countByExample(SecPageEleExample example);

    @DeleteProvider(type=SecPageEleSqlProvider.class, method="deleteByExample")
    int deleteByExample(SecPageEleExample example);

    @Delete({
        "delete from sec_page_ele",
        "where PAGE_ID = #{pageId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer pageId);

    @Insert({
        "insert into sec_page_ele (PAGE_ID, ELE_ID, ",
        "EL_DESC, CREATE_TS, CREATE_UID, ",
        "UPDATE_TS, UPDATE_UID)",
        "values (#{pageId,jdbcType=INTEGER}, #{eleId,jdbcType=VARCHAR}, ",
        "#{elDesc,jdbcType=VARCHAR}, #{createTs,jdbcType=DATE}, #{createUid,jdbcType=INTEGER}, ",
        "#{updateTs,jdbcType=DATE}, #{updateUid,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="pid", before=false, resultType=Integer.class)
    int insert(SecPageEle record);

    @InsertProvider(type=SecPageEleSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="pid", before=false, resultType=Integer.class)
    int insertSelective(SecPageEle record);

    @SelectProvider(type=SecPageEleSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="PAGE_ID", property="pageId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="ELE_ID", property="eleId", jdbcType=JdbcType.VARCHAR),
        @Result(column="EL_DESC", property="elDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="PID", property="pid", jdbcType=JdbcType.INTEGER),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER)
    })
    List<SecPageEle> selectByExample(SecPageEleExample example);

    @Select({
        "select",
        "PAGE_ID, ELE_ID, EL_DESC, PID, CREATE_TS, CREATE_UID, UPDATE_TS, UPDATE_UID",
        "from sec_page_ele",
        "where PAGE_ID = #{pageId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="PAGE_ID", property="pageId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="ELE_ID", property="eleId", jdbcType=JdbcType.VARCHAR),
        @Result(column="EL_DESC", property="elDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="PID", property="pid", jdbcType=JdbcType.INTEGER),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER)
    })
    SecPageEle selectByPrimaryKey(Integer pageId);

    @UpdateProvider(type=SecPageEleSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") SecPageEle record, @Param("example") SecPageEleExample example);

    @UpdateProvider(type=SecPageEleSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") SecPageEle record, @Param("example") SecPageEleExample example);

    @UpdateProvider(type=SecPageEleSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(SecPageEle record);

    @Update({
        "update sec_page_ele",
        "set ELE_ID = #{eleId,jdbcType=VARCHAR},",
          "EL_DESC = #{elDesc,jdbcType=VARCHAR},",
          "PID = #{pid,jdbcType=INTEGER},",
          "CREATE_TS = #{createTs,jdbcType=DATE},",
          "CREATE_UID = #{createUid,jdbcType=INTEGER},",
          "UPDATE_TS = #{updateTs,jdbcType=DATE},",
          "UPDATE_UID = #{updateUid,jdbcType=INTEGER}",
        "where PAGE_ID = #{pageId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(SecPageEle record);
}